<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
	xmlns:s="http://jboss.com/products/seam/taglib"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:rich="http://richfaces.org/rich"
	template="/layout/template.xhtml">

	<ui:define name="body">

		<h:form id="courseForm">

			<rich:panel>
				<h:panelGrid columns="1">

					<s:decorate id="nameField" template="/layout/display.xhtml">
						<ui:define name="label">#{messages['txt.CourseName']}</ui:define>
						<h:outputText value="#{courseHome.instance.name}" />
					</s:decorate>
					<s:decorate id="codeField" template="/layout/display.xhtml">
						<ui:define name="label">#{messages['txt.CourseCode']}</ui:define>
						<h:outputText value="#{courseHome.instance.code}" />
					</s:decorate>
					<s:decorate id="insField" template="/layout/display.xhtml">
						<ui:define name="label">#{messages['txt.Instructor']}</ui:define>
						<h:outputText
							value="#{courseHome.instance.instructor.nameToSrting()}" />
					</s:decorate>
					<s:decorate id="taField" template="/layout/display.xhtml">
						<ui:define name="label">#{messages['txt.TeachingAssistant']}</ui:define>
						<h:outputText
							value="#{courseHome.instance.teachingAssistant.nameToSrting()}" />
					</s:decorate>
				</h:panelGrid>
			</rich:panel>

			<br />

			<h:panelGrid columns="2" width="100%">
				<rich:panel
					rendered="#{identity.hasRole('Instructor') or identity.hasRole('Teaching Assistant')}">
					<rich:dataTable id="studentList" var="stud"
						rendered="#{not empty courseHome.instance.students}"
						value="#{courseHome.instance.students}">
						<h:column>
							<f:facet name="header">#{messages['user.username']}</f:facet>
							<h:outputText value="#{stud.username}" />
						</h:column>
						<h:column>
							<f:facet name="header">#{messages['user.nameSurname']}</f:facet>
							<h:outputText value="#{stud.nameToSrting()}" />
						</h:column>
					</rich:dataTable>

					<s:button id="addStudent" value="#{messages['btn.addStudent']}"
						view="/Student/addStudentToCourse.xhtml" propagation="begin">
						<f:param name="courseId" value="#{courseHome.instance.id}" />
					</s:button>
					<s:button id="addBatchStudent"
						value="#{messages['btn.addStudentAsBatch']}"
						view="/Student/addBatchStudent.xhtml">
						<f:param name="instanceId" value="#{courseHome.instance.id}" />
					</s:button>
				</rich:panel>
				<rich:panel>
					<rich:dataTable id="lectureNotes" var="ln"
						rendered="#{not empty courseHome.instance.lectureNotes}"
						value="#{courseHome.instance.lectureNotes}">
						<h:column>
							<f:facet name="header">#{messages['txt.name']}</f:facet>
							<h:outputText value="#{ln.name}" />
						</h:column>
						<h:column>
							<f:facet name="header">#{messages['txt.uploadDate']}</f:facet>
							<h:outputText value="#{ln.date}">
								<s:convertDateTime type="date" dateStyle="short"
									pattern="dd/MM/yyyy" />
							</h:outputText>
						</h:column>
						<h:column>
							<f:facet name="header">#{messages.filename}</f:facet>
							<h:outputText value="#{ln.fileName}">
							</h:outputText>
						</h:column>
						<h:column>
							<f:facet name="header">#{messages['txt.action']}</f:facet>
							<s:button view="/Course/createLectureNotes.xhtml" id="editLN"
								value="#{messages.editLN}"
								rendered="#{identity.hasRole('Instructor') or identity.hasRole('Teaching Assistant')}"
								propagation="begin">
								<f:param name="lnId" value="#{ln.id}" />
							</s:button>
							<s:button value="#{messages['btn.downloadLN']}"
								action="#{downloadLectureNotes.download}">
								<f:param name="attachmentId" value="#{ln.id}" />
							</s:button>
						</h:column>
					</rich:dataTable>

					<s:button id="createLN" value="#{messages['btn.createLN']}"
						view="/Course/createLectureNotes.xhtml"
						rendered="#{identity.hasRole('Instructor') or identity.hasRole('Teaching Assistant')}"
						action="#{lectureNoteHome.clearInstance()}" propagation="begin">
						<f:param name="courseId" value="#{courseHome.instance.id}" />

					</s:button>
				</rich:panel>
			</h:panelGrid>

			<br />

			<h:panelGrid columns="2" width="100%">
				<rich:panel>
					<f:facet name="header">#{messages['txt.announcements']}</f:facet>
					<rich:dataTable id="annList" var="ann"
						rendered="#{not empty courseHome.instance.announcementsLimited}"
						value="#{courseHome.instance.announcementsLimited}">
						<h:column>
							<f:facet name="header">#{messages['txt.title']}</f:facet>
							<h:outputText value="#{ann.title}" />
						</h:column>
						<h:column>
							<f:facet name="header">#{messages['txt.detail']}</f:facet>
							<h:outputText value="#{ann.detail}" />
						</h:column>
						<h:column>
							<f:facet name="header">#{messages['txt.date']}</f:facet>
							<h:outputText value="#{ann.creationDate}">
								<s:convertDateTime type="date" dateStyle="short"
									pattern="dd/MM/yyyy" />
							</h:outputText>
						</h:column>
						<h:column
							rendered="#{identity.hasRole('Instructor') or identity.hasRole('Teaching Assistant')}">
							<f:facet name="header">#{messages['txt.action']}</f:facet>
							<s:button id="editAnnouncement"
								value="#{messages['btn.editAnnouncement']}"
								view="/Course/createAnnouncement.xhtml"
								action="#{announcementHome.clearInstance()}"
								rendered="#{identity.hasRole('Instructor') or identity.hasRole('Teaching Assistant')}">
								<f:param name="announcementId" value="#{ann.id}" />
							</s:button>
							<!--<s:button id="seeAnnouncement"
								value="#{messages['btn.viewAnnouncement']}"
								view="/Course/viewAnnouncement.xhtml"
								action="#{announcementHome.clearInstance()}" propagation="begin">
								<f:param name="announcementId" value="#{ann.id}" />
							</s:button>
						-->
						</h:column>
					</rich:dataTable>
					<!-- TODO: add all view for announcements -->
					<s:button id="createAnnouncement"
						value="#{messages['btn.createAnnouncement']}"
						view="/Course/createAnnouncement.xhtml"
						rendered="#{identity.hasRole('Instructor') or identity.hasRole('Teaching Assistant')}"
						action="#{announcementHome.clearInstance()}" propagation="begin">
						<f:param name="courseId" value="#{courseHome.instance.id}" />
					</s:button>
				</rich:panel>

				<rich:panel>
					<f:facet name="header">#{messages['txt.ProjectTeams']}</f:facet>
					<rich:dataTable id="teamList" var="team"
						rendered="#{not empty courseHome.instance.projectTeams}"
						value="#{courseHome.instance.projectTeams}">
						<h:column>
							<f:facet name="header">#{messages['txt.title']}</f:facet>
							<s:link id="courseCode" value="#{team.name}" propagation="begin"
								view="/Course/createProjectTeam.xhtml"
								disabled="#{myTeam.isMyTeam(team.id) and identity.hasRole('Student')}">
								<f:param name="teamId" value="#{team.id}" />
								<f:param name="courseId" value="#{courseHome.courseId}" />
							</s:link>
						</h:column>
						<h:column>
							<f:facet name="header">#{messages['txt.studentCount']}</f:facet>
							<h:outputText value="#{team.students.size()}" />
						</h:column>
					</rich:dataTable>

					<s:button id="createProjectTeam"
						value="#{messages['btn.createTeam']}"
						view="/Course/createProjectTeam.xhtml"
						action="#{projectTeamHome.clearInstance()}"
						rendered="#{identity.hasRole('Instructor') or identity.hasRole('Teaching Assistant')}">
						<f:param name="courseId" value="#{courseHome.courseId}" />
					</s:button>
				</rich:panel>
			</h:panelGrid>

			<br />

			<rich:panel>
				<f:facet name="header">#{messages['txt.schedule']}</f:facet>
				<rich:dataTable id="scheList" var="sche"
					rendered="#{not empty courseHome.instance.schedule.activities}"
					value="#{courseHome.instance.schedule.activities}">
					<h:column>
						<f:facet name="header">#{messages['txt.title']}</f:facet>
						<s:link id="activityEditLink" value="#{sche.name}"
							view="/Course/viewSchedule.xhtml" propagation="begin">
							<f:param name="activityId" value="#{sche.id}" />
						</s:link>
					</h:column>
					<h:column>
						<f:facet name="header">#{messages['txt.detail']}</f:facet>
						<h:outputText value="#{sche.desciption}" />
					</h:column>
					<h:column>
						<f:facet name="header">#{messages['txt.dueDate']}</f:facet>
						<h:outputText value="#{sche.dueDate}">
							<s:convertDateTime type="date" dateStyle="short"
								pattern="dd/MM/yyyy" />
						</h:outputText>
					</h:column>
					<h:column>
						<f:facet name="header">#{messages['txt.isSubmissionActivity']}</f:facet>
						<h:outputText value="#{sche.submissionActivity}">

						</h:outputText>
					</h:column>
					<h:column>
						<f:facet name="header">#{messages['txt.reviewOf']}</f:facet>
						<h:outputText value="#{sche.reviewActivity.name}"
							rendered="#{sche.reviewActivity!=null}">
						</h:outputText>
					</h:column>
					<h:column
						rendered="#{identity.hasRole('Instructor') or identity.hasRole('Teaching Assistant')}">
						<f:facet name="header">#{messages['txt.action']}</f:facet>
						<s:button id="activityViewLink" value="Edit Schedule"
							view="/Course/createSchedule.xhtml" propagation="begin"
							rendered="#{identity.hasRole('Instructor') or identity.hasRole('Teaching Assistant')}">
							<f:param name="activityId" value="#{sche.id}" />
						</s:button>
					</h:column>
				</rich:dataTable>

				<s:button id="createSchedule"
					value="#{messages['btn.createScheduleActivity']}"
					view="/Course/createSchedule.xhtml"
					rendered="#{identity.hasRole('Instructor') or identity.hasRole('Teaching Assistant')}"
					action="#{activityHome.clearInstance()}">
					<f:param name="courseId" value="#{courseHome.instance.id}" />
				</s:button>

			</rich:panel>



			<p />
		</h:form>

	</ui:define>

</ui:composition>
